package mathgame.gui;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

import mathgame.ctrl.ControlFactory;
import mathgame.ctrl.Controller;

public class GamePanel extends JPanel{

    protected Controller controller;
    protected ImageIcon icon;
    protected JButton jExitBtn, jHelpBtn;

    public GamePanel(){

        controller = ControlFactory.getController();
        jExitBtn = new JButton();
        jExitBtn.setFont(new Font("monospaced", Font.BOLD, 20));
        jExitBtn.setText("EXIT");
        jHelpBtn = new JButton();
        jHelpBtn.setFont(new Font("monospaced", Font.BOLD, 20));
        jHelpBtn.setText("HELP");

        jExitBtn.addActionListener(actionListener);
        jHelpBtn.addActionListener(actionListener);

    }

    protected ImageIcon createImageIcon(String path,String description) {
        java.net.URL imgURL = getClass().getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL, description);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

    ActionListener actionListener = new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(e.getSource() == jExitBtn){
                System.exit(0);
            }
            else if(e.getSource()== jHelpBtn){
                JOptionPane.showMessageDialog(null, "This is a program were you can sharpen your \n" +
                        "mathematical skills! \n\nYou can either challenge your friends in the \nfurious TIME ATTACK" +
                        " GAME or choose the Practice Mode \nif you wish to improve your skills more calmly." +
                        "\nIf you choose the Practice Mode you can choose which\nchapters you wish to practice. \n\nPlease " +
                        "contact our support at janbanan341@hotmail.com\nif you have any further questions.");
            }
        }
    };
}
